package com.ez.supervise.dao.impl;

import java.util.List;

import com.ez.supervise.core.Page;
import com.ez.supervise.dao.OrgDao;
import com.ez.supervise.dao.base.BaseDaoImpl;
import com.ez.supervise.model.sys.Org;

public class OrgDaoImpl extends BaseDaoImpl implements OrgDao {

    public void insert(Object org) {
	sqlMapClientTemplate.insert("sys.insertOrg", org);
    }

    public Object get(Long id) {
	return (Org) sqlMapClientTemplate.queryForObject("sys.getOrgById", id);
    }

    public void update(Object org) {
	sqlMapClientTemplate.update("sys.updateOrg", org);
    }

    public void delete(Long id) {
	sqlMapClientTemplate.update("sys.deleteOrg", id);
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.ez.supervise.dao.OrgDao#findByCount(com.ez.supervise.core.Page)
     */
    public int findByCount(Page page) {
	return (Integer) getSqlMapClientTemplate().queryForObject("sys.findOrgByCount", page.getConditions());
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.ez.supervise.dao.OrgDao#findByPage(com.ez.supervise.core.Page)
     */
    public List findByPage(Page page) {
	return getSqlMapClientTemplate().queryForList("sys.findOrgByPage", page.getConditions());
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.ez.supervise.dao.OrgDao#findAll()
     */
    public List findAll() {
	return getSqlMapClientTemplate().queryForList("sys.findAll");
    }

    public List findOrgByType(String orgType) {
	return getSqlMapClientTemplate().queryForList("sys.findOrgByType", orgType);
    }

    public int maxOrderByOrg() {
	return (Integer) getSqlMapClientTemplate().queryForObject("sys.maxOrderByOrg");
    }

    public void updateOrderByOrg(Integer orgOrder) {
	getSqlMapClientTemplate().update("sys.updateOrderByOrg", orgOrder);
    }

}
